|
|
@@ -91,13 +91,13 @@ def eqpt_onoff(request):
|
91
|
91
|
|
92
|
92
|
if active == 0:
|
93
|
93
|
try:
|
94
|
|
- user = IsolationPointUserInfo.objects.get(pk=eqpt.ipui_pk)
|
|
94
|
+ ipui = IsolationPointUserInfo.objects.get(pk=eqpt.ipui_pk)
|
95
|
95
|
except IsolationPointUserInfo.DoesNotExist:
|
96
|
|
- user = None
|
97
|
|
- if user:
|
98
|
|
- user.leave_at = tc.utc_datetime()
|
99
|
|
- user.status = False
|
100
|
|
- user.save()
|
|
96
|
+ ipui = None
|
|
97
|
+ if ipui:
|
|
98
|
+ ipui.leave_at = tc.utc_datetime()
|
|
99
|
+ ipui.status = False
|
|
100
|
+ ipui.save()
|
101
|
101
|
|
102
|
102
|
return response()
|
103
|
103
|
|
|
|
@@ -117,12 +117,12 @@ def eqpt_remark(request):
|
117
|
117
|
|
118
|
118
|
# 存放历史备注记录
|
119
|
119
|
try:
|
120
|
|
- user = IsolationPointUserInfo.objects.get(pk=eqpt.ipui_pk)
|
|
120
|
+ ipui = IsolationPointUserInfo.objects.get(pk=eqpt.ipui_pk)
|
121
|
121
|
except IsolationPointUserInfo.DoesNotExist:
|
122
|
|
- user = None
|
123
|
|
- if user:
|
124
|
|
- user.remark += [remark]
|
125
|
|
- user.save()
|
|
122
|
+ ipui = None
|
|
123
|
+ if ipui:
|
|
124
|
+ ipui.remark += [remark]
|
|
125
|
+ ipui.save()
|
126
|
126
|
|
127
|
127
|
return response()
|
128
|
128
|
|
|
|
@@ -177,8 +177,8 @@ def eqpt_result(request):
|
177
|
177
|
).values('macid', 'temperature')
|
178
|
178
|
logs = {log.get('macid'): log.get('temperature') for log in logs}
|
179
|
179
|
|
180
|
|
- infos = IsolationPointUserInfo.objects.filter(point_id=point_id, status=True).values('pk', 'fields')
|
181
|
|
- infos = {info.get('pk'): info.get('fields') for info in infos}
|
|
180
|
+ ipuis = IsolationPointUserInfo.objects.filter(point_id=point_id, status=True).values('pk', 'fields')
|
|
181
|
+ ipuis = {info.get('pk'): info.get('fields') for info in ipuis}
|
182
|
182
|
|
183
|
183
|
total_active_eqpt_num = eqpts.count()
|
184
|
184
|
has_upload_temperature_num = len(logs)
|
|
|
@@ -190,7 +190,7 @@ def eqpt_result(request):
|
190
|
190
|
eqpts = [{**eqpt.data, **{
|
191
|
191
|
'has_upload': eqpt.macid in logs,
|
192
|
192
|
'temperature': logs.get(eqpt.macid, 0),
|
193
|
|
- 'fields': infos.get(eqpt.ipui_pk, {}),
|
|
193
|
+ 'fields': ipuis.get(eqpt.ipui_pk, {}),
|
194
|
194
|
}} for eqpt in eqpts]
|
195
|
195
|
|
196
|
196
|
return response(data={
|
|
|
@@ -222,8 +222,8 @@ def get_screen_data(point=None, point_id=None):
|
222
|
222
|
).values('macid', 'temperature')
|
223
|
223
|
logs = {log.get('macid'): log.get('temperature') or get_old_temperature(point.point_id, log.get('macid')) for log in logs}
|
224
|
224
|
|
225
|
|
- infos = IsolationPointUserInfo.objects.filter(point_id=point.point_id, status=True).values('pk', 'fields', 'observed_days')
|
226
|
|
- infos = {info.get('pk'): {'fields': info.get('fields'), 'observed_days': info.get('observed_days')} for info in infos}
|
|
225
|
+ ipuis = IsolationPointUserInfo.objects.filter(point_id=point.point_id, status=True).values('pk', 'fields', 'observed_days')
|
|
226
|
+ ipuis = {info.get('pk'): {'fields': info.get('fields'), 'observed_days': info.get('observed_days')} for info in ipuis}
|
227
|
227
|
|
228
|
228
|
total_active_eqpt_num = eqpts.count()
|
229
|
229
|
has_upload_temperature_num = len(logs)
|
|
|
@@ -232,8 +232,8 @@ def get_screen_data(point=None, point_id=None):
|
232
|
232
|
eqpts = [{**eqpt.screen_data, **{
|
233
|
233
|
'has_upload': eqpt.macid in logs,
|
234
|
234
|
'temperature': logs.get(eqpt.macid, 0),
|
235
|
|
- 'observed_days': infos.get(eqpt.ipui_pk, {}).get('observed_days', 0),
|
236
|
|
- }, **{field.get('key', ''): field.get('value', '') for field in infos.get(eqpt.ipui_pk, {}).get('fields', {})}} for eqpt in eqpts]
|
|
235
|
+ 'observed_days': ipuis.get(eqpt.ipui_pk, {}).get('observed_days', 0),
|
|
236
|
+ }, **{field.get('key', ''): field.get('value', '') for field in ipuis.get(eqpt.ipui_pk, {}).get('fields', {})}} for eqpt in eqpts]
|
237
|
237
|
reminds = [{
|
238
|
238
|
'name': eqpt.get('name'),
|
239
|
239
|
'room': eqpt.get('room'),
|